package com.winchain.chainbill.tbill.basic.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.tbill.base.po.TbRec;
import com.winchain.chainbill.tbill.base.service.TbRecService;
import com.winchain.chainbill.tbill.biz.TBill;
import com.winchain.chainbill.tbill.biz.TBillEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TBillUpdateSubscriber extends OnErrorNotImplementedSubscriber<TBillEvent<? extends Object>> {
	@Autowired
	private TbRecService tbRecService;

	public void onApplicationEvent(TBillEvent<? extends Object> t) {
		TbRec rec = t.getBill().getRec();
		this.tbRecService.lockByKey(rec.getBillId());
		this.tbRecService.updateNotNull(rec);
	}
}
